<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .apple{
      margin-top: 50px;
      margin-left: 50px;
    }
    .apple input{
      width: 200px;
      height: 35px;
      font-size: 16px;
      outline: none;
    }
    .apple .search{
      border: 1px solid #af3939;
    }
    .result-list{
      display: none;
      border: 1px solid #af3939;
      border-top: none;
      width: 199px;
      margin-top: 0px;
      padding: 0px;
    }
    .result-list li a{
      font-size: 14px;
      text-decoration: none;
      color: #000;
    }
    .result-list li{
      height: 30px;
      line-height: 40px;
      padding-bottom: 10px;
      list-style: none;
      /*鼠标经过显示手指*/
      cursor: pointer;
      padding-left: 10px;
      
    }
    .result-list li:hover{
      
      background-color: #e9e1e1;
      
    }
  </style>
</head>
<body>
  <div class="apple">
    <input  type="search" placeholder="苹果">
    <ul class="result-list">
      <li><a href="#">全部商品</a></li>
      <li><a href="#">苹果13</a></li>
      <li><a href="#">苹果12</a></li>
      <li><a href="#">苹果11</a></li>
      <li><a href="#">苹果笔记本</a></li>
      <li><a href="#">苹果8p</a></li>
    </ul>
  </div>
  <script>
    const input = document.querySelector('[type="search"]')
    const result = document.querySelector('.result-list')
    input.addEventListener('focus',function(){
      input.classList.add('search')
      result.style.display = 'block'
    })
    input.addEventListener('blur',function(){
      
      result.style.display = 'none'
    })
  </script>
</body>
</html>